package com.woniu.stafforder.controller;

import com.woniu.common.util.ResponseData;
import com.woniu.stafforder.entity.dto.OrderEchartsCountDTO;
import com.woniu.stafforder.entity.dto.OrderMonitorCountDto;
import com.woniu.stafforder.es.OrderES;
import com.woniu.stafforder.service.CustomService;
import com.woniu.stafforder.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
public class OrderMonitorIngController {
    @Autowired
    OrderES orderES;
    @Autowired
    private OrderService orderService;
    @Autowired
    private CustomService customService;




    /*
    查询全部省数据
     */
    @GetMapping("/queryAllOrderMon")
    public ResponseData<?> query() {
        customService.saveZgyd();
        List<OrderMonitorCountDto> orderMonitorCountDtos = customService.countOrdersByProvinceAndSourceId();
        System.err.println(orderMonitorCountDtos);
        return new ResponseData<>().ok(orderMonitorCountDtos);
    }

    //    查询货源平台数据
    @GetMapping("/querySourceInfo")
    public ResponseData<?> querySourceInfo(Integer sourceId,@DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) Date startTime,
                                           @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME)Date endTime){
        customService.saveSourceList();
        List<OrderEchartsCountDTO> orderEchartsCountDTOS = customService.countSoruceInfo(sourceId,startTime,endTime);
        return new ResponseData<>().ok(orderEchartsCountDTOS);
    }
}